//
//  JrdContactUsViewController.m
//  iMandarin
//
//  Created by dhcui on 16/11/13.
//  Copyright © 2016年 Singro. All rights reserved.
//

#import "JrdContactUsViewController.h"
#import "JrdCommon.h"
@interface JrdContactUsViewController ()<UITableViewDataSource, UITableViewDelegate>
@property (nonatomic, strong) SCBarButtonItem *leftBarItem;
@property (nonatomic, strong) UIButton    *closeButton;

@end

@implementation JrdContactUsViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self configureTableView];
    [self configureViews];
    [self.tableView setBackgroundColor:JrdTableHeadColor];
    //self.title = "Contact US";
    self.navigationItem.title = @"Contact US";
    self.title = @"Contact US";
}

- (void)configureTableView {
    
    self.tableView                 = [[UITableView alloc] initWithFrame:CGRectMake(0, NAVIGATION_BAR_HEIGHT, SCREEN_WIDTH, SCREEN_HEIGHT - (NAVIGATION_BAR_HEIGHT))];
    //[self.tableView setBackgroundColor:JrdTableHeadColor];
    self.tableView.separatorStyle  = UITableViewCellSeparatorStyleNone;
    self.tableView.delegate        = self;
    self.tableView.dataSource      = self;
    [self.view addSubview:self.tableView];
}

- (void)configureViews{

    self.closeButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.closeButton setImage:[UIImage imageNamed:@"close"] forState:UIControlStateNormal];
    [self.closeButton setTintColor:[UIColor whiteColor]];
    self.closeButton.alpha = 0.5;
    [self.view addSubview:self.closeButton];
    @weakify(self);
    [self.closeButton bk_addEventHandler:^(id sender) {
        @strongify(self);
        
        [self dismissViewControllerAnimated:YES completion:nil];
        
    } forControlEvents:UIControlEventTouchUpInside];

}

- (void)viewWillLayoutSubviews {
    self.closeButton.frame = (CGRect){10, 20, 25, 25};
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    static NSString *CellIdentifier = @"Cell";
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier];
    }
    
    if(0 == indexPath.row){
        UIView *headerLineView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 0.5)];
        headerLineView.backgroundColor = JrdSpeLineColor;
        [cell addSubview:headerLineView];
        
    }
    
    UIFont *myFont = [UIFont fontWithName:@"HelveticaNeue-Light" size:17.0];
    cell.textLabel.font = myFont;
    [cell.textLabel setTextColor:[UIColor blackColor]];
    cell.detailTextLabel.font = myFont;
    cell.detailTextLabel.textColor =Jrd9BColor;// [UIColor JRDColorStandardBlue];
    switch (indexPath.section) {
        case  0:
        {
            cell.textLabel.text = [NSString stringWithFormat:@"%@ :info@imandarin.net", NSLocalizedString(@"jrd_email", nil)];//@"Email:info@imandarin.net";
        }
            break;
        case  1:
        {
            cell.textLabel.text = [NSString stringWithFormat:@"%@ :(0086)400 188 5151", NSLocalizedString(@"jrd_tel", nil)];//@"Tel:(0086)400 188 5151";
        }
            break;
        case  2:
        {
            cell.textLabel.text = [NSString stringWithFormat:@"%@ :www.imandarin.net", NSLocalizedString(@"jrd_web", nil)];//@"Web:www.imandarin.net";
        }
            break;
    }
    [cell.layer setMasksToBounds:YES];
    UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(10, (JRD_TABLE_CELL_HEIGHT - 0.5), SCREEN_WIDTH - 10, 0.5)];
    lineView.backgroundColor = JrdSpeLineColor;
    [cell addSubview:lineView];
    return cell;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 3;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 1;//self.notificationList.list.count;
}


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 10;
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 0;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    UIView* headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.size.width, 10)];
    headerView.backgroundColor = JrdTableHeadColor;//[UIColor clearColor];
    return headerView;
}

- (nullable UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section;   // custom view for footer. will be adjusted to default or specified footer height
{
    UIView* footView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.size.width, 5)];
    footView.backgroundColor = [UIColor clearColor];
    return footView;
    
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
